const http = require('http');
const fs = require('fs');

const url = 'https://www.example.com/image.png';
const dest = './image.png';

const file = fs.createWriteStream(dest);

http.get(url, (response) => {
  response.pipe(file);
});